﻿using PEAnalyzer.InfoDef;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;

namespace PEAnalyzer.ValueConvert.MainPage
{
    public class GridViewIconValueConvert : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            FILE_FORMAT fileFormat = (FILE_FORMAT)value;

            ImageSource imageSource = null;
            switch (fileFormat)
            {
                case FILE_FORMAT.UNKNOWN:
                    imageSource = new BitmapImage(new Uri("ms-appx:///Assets/StoreLogo.png"));
                    break;
                case FILE_FORMAT.EXE:
                    imageSource = new BitmapImage(new Uri("ms-appx:///Assets/EXEIcon.png"));
                    break;
                case FILE_FORMAT.DLL:
                    imageSource = new BitmapImage(new Uri("ms-appx:///Assets/DLLIcon.png"));
                    break;
                case FILE_FORMAT.SYS:
                    imageSource = new BitmapImage(new Uri("ms-appx:///Assets/SYSIcon.png"));
                    break;
                default:
                    break;
            }

            if(imageSource == null)
            {
                throw new Exception("imageSource is null");
            }

            return imageSource;
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            throw new NotImplementedException();
        }
    }
}
